import '../../../core/errors/failure.dart';
import '../../../core/network/api_client.dart';
import '../entity/room_bean.dart';

class RoomListRepositoryImpl {
  final ApiClient apiClient;

  RoomListRepositoryImpl(this.apiClient);

  Future<List<RoomBean>> getDataForNet() async {
    final response = await apiClient.get('/xiaohuanger/roomlist.json');
    if (response.statusCode == 200) {

      return (response.data as List<dynamic>).map((json) => RoomBean.fromJson(json as Map<String, dynamic>)).toList();
    } else {
      throw ServerFailure('getDataForNet failed');
    }
  }
}
